#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                    [searchdiv]
                    <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                        搜索
                    </button>
                    [searchmorediv]
                    </p>
                    <i class="layui-icon layui-icon-triangle-r"></i>
                    <span class="color_green">[pagename]列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container" style="float:left">
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="Add[model]">
                                <i class="layui-icon">&#xe608;</i> 添加[pagename]
                            </button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="Edit[model]">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="Del[model]">删除</button>
                        </div>
                        <div id="bar_desc"></div>
                    </script>
                    [searchmore]
                    [templet]
                    [tabletoolbar]
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'util', 'myTool','drawer'], function () {
        var $ = layui.$,myTable = layui.myTable, myTool = layui.myTool;
        /**
        * 表格
        */
        tableindex = layui.myTable.render({
                    elem: '#table_1', url: '[model]ListDataApi'
                    ,title: '列表'
                    , where: {}
            ,cols: [[
                        {type: 'checkbox',width:36, fixed: true}
                                [columns]
                    ]]
            , page:true, limit:10
            , serviceSort: true, initSort: {field: '[modelkey]', type: 'desc'}
            , editField:{url: 'Modify[model]FieldApi', key:'[modelkey]'}
            , done: function (res, curr, count) {
                $("#bar_desc").html("");
            }
        });

        [searchmorejs]

         /**
         * 按钮事件
         */
         layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.config.where={[searchjs]};
                tableindex.reload({where:tableindex.config.where, page: {curr: 1}});
            }
            ,DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

    /**
     * 工具栏事件
     */
        layui.table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                Add[model]:function () {
                index = top.layer.open({
                   type: 2, offset: '60px', area: ['800px', '580px'], title: ['添加[pagename]', 'font-size:15px;'],
                    content: ["[path]/Add[model]", 'no'],
                    end: function () {
                        tableindex.reload({});
                    }
                });
            }
            ,Edit[model]:function () {
                myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                index = top.layer.open({
                    type: 2, offset: '60px', area: ['800px', '580px'], title: ['修改[pagename][' + data[0].[modelkey] + ']', 'font-size:15px;'],
                    content: ["[path]/Edit[model]?[modelkey]=" + data[0].[modelkey], 'no'],
                    end: function () {
                        tableindex.reload({});
                    }
                });
            });
            }
            ,Del[model]:function () {
            myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                index = top.layer.confirm('你是否确认删除[pagename]【' + data[0].[modelkey] + '】', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                    myTool.postMsg("Del[model]Api", {[modelkey]:data[0].[modelkey]
                }, function () {
                    top.layer.close(index2);
                    tableindex.reload();
                });
            });
            });
            }, DelMore[model]: function () {
            myTool.doMoreSelect(layui.myTable.checkStatus('table_1'), {key: '[modelkey]'}, function (data, keys) {
                index = top.layer.confirm('你是否确认批量删除选中的[pagename]【' + data.length + '】数据', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                    myTool.postMsg("DelMore[model]Api", {keys: keys}, function () {
                    top.layer.close(index2);
                    tableindex.reload();
                });
            });
            });
            }
        });
    });

    [tabletooljs]

    layui.form.on('checkbox(Change[model]Tag)', function (obj) {
        myTool.postMsg("ChangeTag[model]Api", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
            layer.tips(result.msg, obj.othis);
        });
    });
    layui.form.on('switch(Change[model]Tag)', function (obj) {
        myTool.postMsg("ChangeTag[model]Api", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
            layer.tips(result.msg, obj.othis);
        });
    });
    });
</script>
#include("../../comm/Foot.html")